#pragma once
#include "Metodos.h"
namespace validacionCadenas {

	using namespace System;
	using namespace System::ComponentModel;
	using namespace System::Collections;
	using namespace System::Windows::Forms;
	using namespace System::Data;
	using namespace System::Drawing;

	/// <summary>
	/// Summary for Form1
	/// </summary>
	public ref class Form1 : public System::Windows::Forms::Form
	{
	public:
		Form1(void)
		{
			InitializeComponent();
			//
			//TODO: Add the constructor code here
			//
		}

	protected:
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		~Form1()
		{
			if (components)
			{
				delete components;
			}
		}
	private: System::Windows::Forms::Button^  btnValidar;
	protected: 
	private: System::Windows::Forms::TextBox^  txtCadena;
	private: System::Windows::Forms::Label^  lblCadena;

	private:
		/// <summary>
		/// Required designer variable.
		/// </summary>
		System::ComponentModel::Container ^components;

#pragma region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		void InitializeComponent(void)
		{
			this->btnValidar = (gcnew System::Windows::Forms::Button());
			this->txtCadena = (gcnew System::Windows::Forms::TextBox());
			this->lblCadena = (gcnew System::Windows::Forms::Label());
			this->SuspendLayout();
			// 
			// btnValidar
			// 
			this->btnValidar->Location = System::Drawing::Point(148, 85);
			this->btnValidar->Name = L"btnValidar";
			this->btnValidar->Size = System::Drawing::Size(75, 23);
			this->btnValidar->TabIndex = 0;
			this->btnValidar->Text = L"Validar";
			this->btnValidar->UseVisualStyleBackColor = true;
			this->btnValidar->Click += gcnew System::EventHandler(this, &Form1::btnValidar_Click);
			// 
			// txtCadena
			// 
			this->txtCadena->Location = System::Drawing::Point(43, 29);
			this->txtCadena->MaxLength = 10;
			this->txtCadena->Name = L"txtCadena";
			this->txtCadena->Size = System::Drawing::Size(278, 20);
			this->txtCadena->TabIndex = 1;
			// 
			// lblCadena
			// 
			this->lblCadena->AutoSize = true;
			this->lblCadena->Location = System::Drawing::Point(43, 135);
			this->lblCadena->Name = L"lblCadena";
			this->lblCadena->Size = System::Drawing::Size(0, 13);
			this->lblCadena->TabIndex = 2;
			// 
			// Form1
			// 
			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
			this->ClientSize = System::Drawing::Size(367, 160);
			this->Controls->Add(this->lblCadena);
			this->Controls->Add(this->txtCadena);
			this->Controls->Add(this->btnValidar);
			this->Name = L"Form1";
			this->Text = L"Form1";
			this->ResumeLayout(false);
			this->PerformLayout();

		}
#pragma endregion
	private: System::Void btnValidar_Click(System::Object^  sender, System::EventArgs^  e) {
				 Metodos m;
				 
				 String ^ cadena = txtCadena->Text;
				 int tam=txtCadena->Text->Length;
				 char a[10];
				 
				 for(int i=0;i<tam;++i){
					 a[i]=cadena[i];
				 }

				 if(m.validarCadena(a,tam)){ 
					 MessageBox::Show("La Palabra SI pertenece al lenguaje: (0+1)*"); 
				 }else{ 
					 MessageBox::Show("La palabra NO pertenece al lenguaje: (0+1)*");
				 }
			 }
	};
}

